1. Field of the Invention
The present invention relates generally to graphical user interfaces, and in particular, to a method, apparatus, and article of manufacture for connecting shapes using a bi-directional connector object and for resolving connections using an external connection manager.
2. Description of the Related Art
The use of Computer Assisted Drafting (CAD) application programs is well known in the art. Some CAD programs provide templates and palettes that help users create documents, graphical presentations, etc. These templates and palettes provide only limited assistance and do little to help the user connect standard CAD components, define new components, or define methods of manipulating the components within the CAD program.
Many standard components have one or more unidirectional plugs or one or more unidirectional sockets that can connect to another socket or plug respectively. Each plug or socket is an instance of an object that allows the socket or plug to connect in one direction with a plug or socket respectively. For example, an instance of a plug object on a shape may connect to an instance of a socket object on another shape. Such plugs and sockets are unidirectional. Thus, a plug may only connect into a socket and cannot receive another plug or a socket. Similarly, a socket may only receive a plug and cannot connect into another socket or a plug.
As a result of the unidirectional nature of the plugs and sockets, various circumstances may result. For instance, if a first shape with a plug connector is plugged into a socket of a second shape and the first shape is moved, the plug will most likely unplug and separate from the socket. However, if the second shape is moved, the plug may follow the socket. Such properties and circumstances ate undesirable and frustrating to users.
Consequently, there is a need in the art for improved techniques for connecting shapes in a CAD or drawing program.
To address the requirements described above, the present invention discloses a method, apparatus, and article of manufacture for connecting objects in a drawing application. One or more connector objects owned by a shape object provide connectivity to other connector objects of other shape objects. In a connector object, plug and socket behavior ate merged into a single connector object that no longer requires the use of separate plug and socket objects. Using flags, each connector object may be configured to behave as either a plug (referred to as a plug connector), socket (referred to as a socket connector), or both. Since connector objects can simultaneously act as plugs and sockets, connector objects support bi-directional connections.
The task of resolving/updating connections and connector objects may be delegated to an external connection manager. Given a list of changed connections, the connection manager uses a spanning-tree algorithm to efficiently update all connections, including circular references. Accordingly, the connection manager recursively processes connector objects in a drawing until all necessary connector objects and shape objects have been resolved/updated. Having an external connection manager allows complete control over when connections are resolved.